<?php

namespace App\Models\Rooms;

use App\Models\Members;
use App\Models\Rooms\RoomGoods;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

class RoomsGoodsBuy extends Model
{
    protected $table = 'room_goods_buys';

    protected $fillable = [
        'action_at','status','shopning_code','shopning_code'
    ];
    public function member()
    {
        return $this->hasOne(Members::class,'id','member_id');
    }

    public function room_goods()
    {
        return $this->hasOne(RoomGoods::class,'id','room_goods_id');
    }

     public function getBankSiteAttribute($value)
    {
        if($value == 0){
            return '中国银行';
        }else if($value == 1)
        {
            return '农行';
        }else if($value == 2)
        {
            return '建行';
        }else if($value == 3)
        {
            return '工行';
        }
    }

    public function getGoodsGoldenLevelAttribute($value)
    {
        if($value == 1){
            return '初级场';
        }else if($value == 2)
        {
            return '中级场';
        }else if($value == 3)
        {
            return '高级场';
        }
    }

    public function getCreatedAtAttribute($value)
    {
        return is_null($value) ? '--' : Carbon::parse($value)->toDateString();
    }

    public function getActionAtAttribute($value)
    {
        return is_null($value) ? '--' : Carbon::parse($value)->toDateString();
    }
}
